package cn.edu.xjtu.nbrash.xbarsuite;

import java.util.LinkedHashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import cn.edu.xjtu.nbrash.xbarsuite.floatbutton.RashFloatButton;

public class RashMoreActivity extends Activity {

	private String[] items;
	private Map<String, Intent> intents;
	private ListView listView;

	private void initIntentsMap() {
		intents = new LinkedHashMap<String, Intent>();

		putIntents(R.string.title_activity_rash_float_button,
				RashFloatButton.class);

		putIntents(R.string.title_activity_about, AboutActivity.class);
	}

	private void putIntents(int rsid, Class<?> cls) {
		intents.put(getString(rsid), new Intent(this, cls));
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_rash_more);

		listView = (ListView) findViewById(R.id.list_more);
		initIntentsMap();
		items = intents.keySet().toArray(new String[0]);
		listView.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, items));

		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				startActivity(intents.get(items[position]));
			}
		});

	}
}
